package com.yulongtian.oneProblemEveryDay.month202301;

/**
 * https://leetcode.cn/problems/check-if-number-has-equal-digit-count-and-digit-value/
 * 可
 *
 * @author yulongTian
 * @create 2023-01-11 10:34
 */
public class Test09 {
    public static void main(String[] args) {

    }

    public static boolean digitCount(String num) {
        int[] cnt = new int[10];
        for (int i = 0; i < num.length(); i++) {
            cnt[num.charAt(i) - '0']++;
        }

        boolean flag = true;
        for (int i = 0; i < Math.min(cnt.length, num.length()); i++) {
            if (cnt[i] != (num.charAt(i) - '0')) {
                flag = false;
            }
        }

        return flag;
    }

}
